<template>
  <div class="news-area">
    <div class="news-header">
      <h2 class="news">热点新闻</h2>
      <hr class="line"/>
      <span class="intro">hot news</span>
    </div>
    <div class="news-body">
      <div class="news-row">
        <div class="news-panel-left">
          <a :href="left_up_href" target="_blank"><h2>{{left_up_title}}</h2></a>
          <a :href="left_up_href" target="_blank"><p>{{left_up_des}}</p></a>
        </div>
        <div class="news-link-left">
          <a :href="left_up_href" target="_blank"><img :src="left_up_img" /></a>
        </div>
        <div class="news-link-right">
          <a :href="right_up_href" target="_blank"><img :src="right_up_img" /></a>
        </div>
        <div class="news-panel-right">
          <a :href="right_up_href" target="_blank"><h2>{{right_up_title}}</h2></a>
          <a :href="right_up_href" target="_blank"><p>{{right_up_des}}</p></a>
        </div>
      </div>

      <div class="news-row">
        <div class="news-panel-left">
          <a :href="left_center_href" target="_blank"><h2>{{left_center_title}}</h2></a>
          <a :href="left_center_href" target="_blank"><p>{{left_center_des}}</p></a>
        </div>
        <div class="news-link-left">
          <a :href="left_center_href" target="_blank"><img :src="left_center_img" /></a>
        </div>
        <div class="news-link-right">
          <a :href="right_center_href" target="_blank"><img :src="right_center_img" /></a>
        </div>
        <div class="news-panel-right">
          <a :href="right_center_href" target="_blank"><h2>{{right_center_title}}</h2></a>
          <a :href="right_center_href" target="_blank"><p>{{right_center_des}}</p></a>
        </div>
      </div>

      <div class="news-row">
        <div class="news-panel-left">
          <a :href="left_down_href" target="_blank"><h2>{{left_down_title}}</h2></a>
          <a :href="left_down_href" target="_blank"><p>{{left_down_des}}</p></a>
        </div>
        <div class="news-link-left">
          <a :href="left_down_href" target="_blank"><img :src="left_down_img" /></a>
        </div>
        <div class="news-link-right">
          <a :href="right_down_href" target="_blank"><img :src="right_down_img" /></a>
        </div>
        <div class="news-panel-right">
          <a :href="right_down_href" target="_blank"><h2>{{right_down_title}}</h2></a>
          <a :href="right_down_href" target="_blank"><p>{{right_down_des}}</p></a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {getNews} from '@/api/news'

export default {
  name: 'news',
  data() {
    return {
      left_up_href: '',
      left_up_title: '',
      left_up_des: '',
      left_up_img: '',
      right_up_href: '',
      right_up_img: '',
      right_up_title: '',
      right_up_des: '',
      left_center_href: '',
      left_center_title: '',
      left_center_des: '',
      left_center_img: '',
      right_center_href: '',
      right_center_title: '',
      right_center_des: '',
      right_center_img: '',
      left_down_href: '',
      left_down_title: '',
      left_down_des: '',
      left_down_img: '',
      right_down_href: '',
      right_down_img: '',
      right_down_title: '',
      right_down_des: ''
    }
  },
  methods: {
    getNewsList() {
      getNews().then(res => {
        let newsList = res.data.data
          this.left_up_href = newsList[0].hrefUrl
          this.left_up_title = newsList[0].title
          this.left_up_des = newsList[0].des
          this.left_up_img = newsList[0].imgUrl
          this.right_up_href = newsList[1].hrefUrl
          this.right_up_img = newsList[1].imgUrl
          this.right_up_title = newsList[1].title
          this.right_up_des = newsList[1].des
          this.left_center_href = newsList[2].hrefUrl
          this.left_center_title = newsList[2].title
          this.left_center_des = newsList[2].des
          this.left_center_img = newsList[2].imgUrl
          this.right_center_href = newsList[3].hrefUrl
          this.right_center_title = newsList[3].title
          this.right_center_des = newsList[3].des
          this.right_center_img = newsList[3].imgUrl
          this.left_down_href = newsList[4].hrefUrl
          this.left_down_title = newsList[4].title
          this.left_down_des = newsList[4].des
          this.left_down_img = newsList[4].imgUrl
          this.right_down_href = newsList[5].hrefUrl
          this.right_down_img = newsList[5].imgUrl
          this.right_down_title = newsList[5].title
          this.right_down_des = newsList[5].des
      })
    }
  },
  created() {
    this.getNewsList()
  }
}
</script>

<style>
.news-header {
  text-align: center;
  margin-top: 30px;
}
.news {
  font-weight: 600;
  color: #333;
  letter-spacing: 1px;
  font-family: Ek Mukta;
  font-size: 36px;
  margin: 0;
}
.news-body {
  width: 1270px;
  padding: 20px 15px 10px;
  margin: 0px auto;
  position: relative;
}
.news-row {
  display: flex;
  height: 180px;
  justify-content: space-between;
  margin-bottom: 40px;
}
.news-row h2 {
  font-size: 22px;
  color: #000;
}
.news-row p {
  line-height: 1.5;
  color: #3f5b50;
}
.news-panel-left {
  width: 360px;
  text-align: right;
}
.news-link-left img,
.news-link-right img {
  border: 7px double #eee;
  border-radius: 20px;
  width: 220px;
  height: 150px;
}
.news-panel-right {
  width: 360px;
  text-align: left;
}
</style>
